Simple-minded matrix book-keeping
September-07-10
3:23 PM
Why is it that the two programs below produce the same output, up to an additive constant term?
Program 1: (Alexander-Wirtinger)
R[gd_GD] := Module[
   {n, mat, arcs, k},
   n = Length[gd]; arcs = Arcs[gd];
   mat = Table[0, {n}, {n + 1}];
   k = 0; gd /. Ar[t_, h_, s_] :> {
         mat[[++k, arcs[[h]]]] = -1;  mat[[k, arcs[[t]]]] = 1 - X^s;
         mat[[k, arcs[[h]] + 1]] = X^s
      };
   mat
];
IM = Append[Inverse[Drop[R[gd], None, -1]], Table[0, {n}]];
j = 0;
Simplify[Expand[Plus @@ (gd /. Ar[t_, h_, s_] :>
     (++j; (IM[[arcs[[t]], j]] - IM[[arcs[[h]] + 1, j]]) s X^s)
)]]
Program 2 (tail scattering towards the head):
EZ2[gd_GD] := Module[
   {n, r, arcs, j},
   n = Length[gd];  r = R[gd];
   arcs = Arcs[gd];
   j = 0;  Simplify[Plus @@ (
      gd /. Ar[t_, h_, s_] :>
        s*Inverse[Append[r, e[n + 1, arcs[[h]]]]][[
           arcs[[t]], ++j
        ]]
      )]
   ];